package com.niiwoo.civet.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * Created by zhangwanli on 2017/9/23.
 */
public class UserEnum {

    @AllArgsConstructor
    @Getter
    public enum Gender {
        UNKNOWN(0, "未知"),
        MALE(1, "男"),
        FEMALE(2, "女");

        private int value;
        private String desc;

        public String descOf(Integer value) {
            if (value == null) {
                return "";
            }
            for (Gender gender : values()) {
                if (gender.value == value) {
                    return gender.desc;
                }
            }
            return "";
        }

        public Gender enumOf(Integer value) {
            if (value != null) {
                for (Gender gender : values()) {
                    if (gender.value == value) {
                        return gender;
                    }
                }
            }
            return null;
        }

    }

    @AllArgsConstructor
    @Getter
    public enum RegisterChannel {

        PLATFORM_APP_IOS((byte) 11, "你我金融APP-IOS"),
        PLATFORM_APP_ANDROID((byte) 12, "你我金融APP-安卓"),
        PLATFORM_H5((byte) 2, "你我金融H5"),
        RONG_360((byte) 3, "融360"),
        TUAN_DAI((byte) 4, "团贷网"),
        HAO_BANG_DAI((byte) 5, "好帮贷"),
        HOUSE_BABY((byte) 6, "房宝宝"),
        LAN_LING_JIE((byte) 7, "蓝领借"),
        QUANT_GROUP((byte) 8, "量化派"),
        BORROW_FAST((byte) 9, "借钱快"),
        CARD_NIU((byte) 13, "卡牛"),
        ORG((byte) 14, "机构极速借"),
        HUIJIE((byte) 15, "汇介"),
        FANLITOU((byte) 16, "返利投"),
        ;

        private Byte value;
        private String desc;

        public static RegisterChannel enumOf(byte value) {
            for (RegisterChannel channel : values()) {
                if (channel.value == value) {
                    return channel;
                }
            }
            return null;
        }

        public static boolean isPlatformChannel(byte value) {
            RegisterChannel c = enumOf(value);
            return c == PLATFORM_APP_IOS || c == PLATFORM_APP_ANDROID || c == PLATFORM_H5;
        }

    }

    @AllArgsConstructor
    @Getter
    public enum RegisterDeviceType {

        ANDROID((byte) 0, "安卓"),
        IOS((byte) 1, "IOS"),
        WEB((byte) 2, "网页");

        private Byte value;
        private String desc;

        public static RegisterDeviceType enumOf(byte value) {
            for (RegisterDeviceType deviceType : values()) {
                if (deviceType.value == value) {
                    return deviceType;
                }
            }
            return null;
        }

    }

    /**
     * 身份类型
     */
    @Getter
    @AllArgsConstructor
    public enum IdentityTag {
        NO_IDENTITY("1", "无身份"),
        INVESTOR("2", "投资人"),
        BORROWER("3", "借款人"),
        INVEST_BORROWER("2,3", "投资、借款人");
        private String type;
        private String desc;

    }

    /**
     * 引流渠道
     */
    @Getter
    @AllArgsConstructor
    public enum UserdrainageChannel {
        APP("app", "APP"),
        XINHUALIAN("xinhualian", "新华联"),
        XINHUALIANDICHAN("xinhualiandichan", "新华联地产");
        private String channelCode;
        private String channelName;

        public static UserdrainageChannel enumOf(String channelCode) {
            for (UserdrainageChannel enumObj : values()) {
                if (enumObj.channelCode.equals(channelCode)) {
                    return enumObj;
                }
            }
            return null;
        }
    }

}
